package com.ydj.framework.resolver;

import com.ydj.framework.exception.VerifyTokenException;
import com.ydj.framework.redis.RdsBaseLoginInfo;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;

import javax.annotation.PostConstruct;
import java.util.ArrayList;
import java.util.List;

/**
 * 参数转换器的基类
 */
@Configuration
public abstract class BaseArgumentResolver<T extends RdsBaseLoginInfo>{

    @Getter
    @Setter
    @Accessors(chain = true)
    @AllArgsConstructor
    public static class ArgFormat {
        private String argName;
        private Class<?> argType;
    }

    @Getter
    private final List<ArgFormat> argFormatList = new ArrayList<>();

    protected abstract void createArgFormat(List<ArgFormat> list);

    protected abstract Object doResolveArgument(String parameterName, T info) throws VerifyTokenException;

    public abstract String prePath();

    protected BaseArgumentResolver() {
        createArgFormat(argFormatList);
    }

}